package com.ruoyi.app.common.constant;

import com.ruoyi.common.config.Global;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class UploadConstants {

    @Getter
    @AllArgsConstructor
    public enum ModelEnum {
        MEMBER_AVATAR(1) {
            @Override
            public String getUploadPath() {
                return Global.getMemberAvatarPath();
            }
        },
        CREDIT_PRODUCT_EXCHANGE_QR_CODE(2) {
            @Override
            public String getUploadPath() {
                return Global.getExchangeCodePath();
            }
        },
        LOTTERY_EXCHANGE_QR_CODE(3) {
            @Override
            public String getUploadPath() {
                return Global.getProfile() + "/lottery_exchange";
            }
        },
        WORKS_PRE_POSTER(4) {
            @Override
            public String getUploadPath() {
                return Global.getProfile() + "/works_pre_poster";
            }
        },
        NULL(0) {
            @Override
            public String getUploadPath() {
                return "";
            }
        },
        ;

        private int modelValue;

        public abstract String getUploadPath();

        public static ModelEnum match(int model) {
            for (ModelEnum one : ModelEnum.values()) {
                if (one.getModelValue() == model) {
                    return one;
                }
            }
            return ModelEnum.NULL;
        }
    }
}
